<template>
  <div>
    <f-search-form :more='true' @searchHandler='searchHandler'>
      <f-search-form-item label='订单编号' name='orderNo' />
      <f-search-form-item label='业务员' name='saleManName' />
      <f-search-form-item label='单位名称' name='customName' />
      <f-search-form-item label='部门' name='deptId' type='select' :data='api.hyorder.listByCompanyId' :params='queryParam' value-key='deptId' label-key='deptName' slot='advanced' />
      <f-search-form-item label='发货日期' type='range' name='beginDate' slot='advanced' />
    </f-search-form>
    <f-table ref='table' rowKey='orderId' :columns='columns' :scroll='{x:true}' :multiple='false' :operator='operator' :params='queryParam' :api='api.hyorder' handler='hyCalculateOrderTab1ListHandler'>
      <span slot='sendType' slot-scope='text, record, index'>
        <a-tag color='#2db7f5' v-if='text==1'>现款</a-tag>
        <a-tag color='#FF0000' v-if='text==2'>预收款</a-tag>
        <a-tag color='#87d068' v-if='text==3'>资保金</a-tag>
        <a-tag color='purple' v-if='text==4'>全额资信</a-tag>
      </span>
      <span slot='orderType' slot-scope='text, record, index'>
           <a-tag color='#2db7f5' v-if='text=="CHA"'>销售</a-tag>
           <a-tag color='#FF0000' v-if='text=="CHC"'>退货</a-tag>
           <a-tag color='purple' v-if='text==4'>票折</a-tag>
       </span>
      <span slot='deptType' slot-scope='text, record, index'>
        <a-tag color='#87d068' v-if='text=="ZS"'>招商</a-tag>
        <a-tag color='#108ee9' v-if='text=="ZY"'>自营</a-tag>
      </span>
    
      <span slot='action' slot-scope='text, record'>
          <template>
            <a href='javascript:;' @click='$refs.caclulateDrawer.showDrawer(record)'>详情</a>
            <a-divider type='vertical' />
            <a @click='startProcess(record.orderId,"hyCalculateStartProcessHandler","确定提交费用结算申请吗?")' v-if='record.calculateState==0'>提交</a>
          </template>
        </span>
    </f-table>
    <caclulate-apply-drawer ref='caclulateDrawer'></caclulate-apply-drawer>
  </div>
</template>
<script>
import api from "../../../js/api"
import { processMixins } from "@/core/mixins/processMixins"
import CaclulateApplyDrawer from "./components/caclulate_apply_drawer"

export default {
  name: "Tab1",
  components: { CaclulateApplyDrawer },
  mixins: [processMixins],
  data() {
    let me = this
    //操作按钮
    let operator = []
    return {
      api: Object.assign(api, this.api),
      //列表初始化查询参数
      queryParam: {
       
      },
      activeKey: "0",
      // 表头
      columns: [
        {
          title: "序号",
          width: "60px",
          align: "center",
          fixed: "left",
          customRender: (text, record, index) => index + 1
        },
        {
          title: "发(退)货日期",
          align: "center",
          fixed: "left",
          width: "110px",
          dataIndex: "sendDate"
        },
        {
          title: "订单编号",
          align: "center",
          width: "110px",
          dataIndex: "orderNo"
        },
        {
          title: "出库单号",
          align: "center",
          width: "110px",
          dataIndex: "outOrderNo"
        },
        {
          title: "单据类型",
          align: "center",
          width: "80px",
          dataIndex: "orderType",
          scopedSlots: { customRender: "orderType" },
          filters: [
            {
              text: "销售",
              value: "CHA"
            },
            {
              text: "退货",
              value: "CHC"
            },
            {
              text: "票折",
              value: "PZ"
            }
          ],
          filterMultiple: false
        },
        {
          title: "部门",
          align: "left",
          width: "120px",
          dataIndex: "deptName"
        },
        {
          title: "业务类型",
          align: "left",
          width: "80px",
          dataIndex: "deptType",
          scopedSlots: { customRender: "deptType" },
          filters: [
            {
              text: "招商",
              value: "ZS"
            },
            {
              text: "自营",
              value: "ZY"
            }
          ],
          filterMultiple: false
        },
        {
          title: "业务员",
          align: "left",
          width: "90px",
          dataIndex: "saleManName"
        },
        {
          title: "业务编码",
          align: "left",
          width: "120px",
          dataIndex: "businessCode"
        },
        {
          title: "发货方式",
          align: "left",
          dataIndex: "sendType",
          width: "100px",
          scopedSlots: { customRender: "sendType" }
        },
        {
          title: "区域",
          align: "left",
          width: "80px",
          dataIndex: "businessArea"
        },
        {
          title: "单位名称",
          align: "left",
          ellipsis: true,
          width: "130px",
          dataIndex: "customName"
        },
        {
          title: "创建日期",
          dataIndex: "createTime",
          width: 150,
          align: "left",
          sorter: true
        },
        {
          title: "开票员",
          align: "center",
          fixed: "right",
          dataIndex: "nickName"
        },
        {
          title: "操作",
          align: "center",
          dataIndex: "action",
          width: "100px",
          fixed: "right",
          scopedSlots: { customRender: "action" }
        }
      ],
      operator: operator,
      processImageVisible: false,
      processInstanceId: null
    }
  },
  created() {
  },
  methods: {
    onLoad() {
      this.$refs.table.refresh()
    },
    //修改核算状态
    updateCaclulateOrder(order) {
      this.http.confirm(this, {
        content: "确认核算完成?",
        url: api.hyorder.updateCaclulateOrder,
        data: {
          orderId: order.orderId
        },
        success: (me, data) => {
          this.$refs.table.refresh()
        }
      })
    },
    changeHandler(activeKey) {
      this.activeKey = activeKey
      this.$refs.table.refresh(true, { activeKey: this.activeKey })
    }
  }
}
</script>
